package com.jugheadzhou.auth.core.message.consumer.receiver;

import com.jugheadzhou.auth.core.message.IMessage;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

/**
 * 死信队列消息监听
 *
 * @author jugheadzhou
 * @date 2021-12-02
 */
@Slf4j
public class WsGlobalConDlxReceiver extends AbstractRabbitmqReceiver {

    public static final String QUEUE_NAME = "ws.global.con.dlx";

    @Override
    @RabbitListener(queues = QUEUE_NAME)
    @RabbitHandler
    public void handle(IMessage iMessage, Channel channel, Message message) {
        super.handle(iMessage, channel, message);
    }

    /**
     * 处理消息内容
     *
     * @param iMessage
     * @param channel
     * @param message
     * @throws Exception
     */
    @Override
    public void handleMessage(IMessage iMessage, Channel channel, Message message) throws Exception {
        log.info("TODO 死信业务处理: {}", iMessage);
    }

    /**
     * 处理消息异常
     *
     * @param iMessage
     * @param channel
     * @param message
     * @param e
     */
    @Override
    public void handleException(IMessage iMessage, Channel channel, Message message, Exception e) {
        log.error("TODO 死信业务异常处理: {}", iMessage, e);
    }
}
